package com.zlk.algorithm.huawei.leetcode.binaryTree;

import com.zlk.algorithm.util.TreeNode;

/**
 * @program: algorithm
 * @ClassName Code24_invertTree
 * @description:翻转二叉树
 * @author: slfang
 * @create: 2025-01-08 10:41
 * @Version 1.0
 **/
public class Code24_invertTree {


    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode left = invertTree(root.left);
        TreeNode right = invertTree(root.right);
        root.left = right;
        root.right = left;
        return root;
    }
}
